//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.controller;

import com.example.common.Result;
import com.example.entity.Recruitment;
import com.example.service.RecruitmentService;
import com.example.service.RecruitmentapplicationService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping({"/recruitment"})
public class RecruitmentController {
    @Resource
    private RecruitmentService recruitmentService;


    public RecruitmentController() {
    }

    @GetMapping({"/selectAll"})
    public Result selectAll(@RequestParam Integer clubId) {
        List<Recruitment> list = this.recruitmentService.selectAll(clubId);
        return Result.success(list);
    }

    @GetMapping({"/selectById/{id}"})
    public Result selectById(@PathVariable Integer id) {
        Recruitment recruitment = this.recruitmentService.selectById(id);
        return Result.success(recruitment);
    }

    @GetMapping({"/selectByOne"})
    public Result selectByOne(@RequestParam Integer id, @RequestParam(required = false) String no) {
        Recruitment recruitment = this.recruitmentService.selectById(id);
        return Result.success(recruitment);
    }

    @GetMapping({"/selectList"})
    public Result selectList(Recruitment recruitment) {
        List<Recruitment> list = this.recruitmentService.selectList(recruitment);
        return Result.success(list);
    }

//    @GetMapping({"/selectPage"})
//    public Result selectPage(Recruitment recruitment, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) Integer studentId) {
//        PageInfo<Recruitment> pageInfo = this.recruitmentService.selectPage(recruitment, pageNum, pageSize, studentId);
//        return Result.success(pageInfo);
//    }

    @PostMapping({"/add"})
    public Result add(@RequestBody Recruitment recruitment) {
        this.recruitmentService.add(recruitment);
        return Result.success();
    }

    @PostMapping({"/update"})
    public Result update(@RequestBody Recruitment recruitment) {
        this.recruitmentService.updateById(recruitment);
        return Result.success();
    }

    @DeleteMapping({"/delete/{id}"})
    public Result delete(@PathVariable Integer id) {
        this.recruitmentService.deleteById(id);


        return Result.success();
    }

    @DeleteMapping({"/deleteBatch"})
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        this.recruitmentService.deleteBatch(ids);
        return Result.success();
    }

    /**
     * 根据学生加入的社团id查询招募信息
     * @param clubIds
     * @return
     */
    @GetMapping("/selectByClubs")
    public Result selectByClubs(@RequestParam List<Integer> clubIds,@RequestParam String title) {
        List<Recruitment> list = this.recruitmentService.selectByClubs(clubIds,title);
        return Result.success(list);
    }
}
